﻿function LoginOut() {
    location.href = "/BaseArea/Auth/Login";
}

function LoginDialog() {
    var id = "loginDialog";
    ShowDialog({
        id: id,
        title: "请登录",
        content: "这是一个登录框",
        url: "/Areas/BaseArea/Html/_Login.html",
        yestxt: "登录",
        yesfn: function () {
            DialogLoading({ id: id }, true);
            $("#loginForm").PostForm({
                vfn: function () {
                    return true;
                },
                success: function (data) {
                    msgsuc(data);
                    CloseDialog(id);
                },
                error: function (data) {

                    var $obj = $("#modal-" + id, $("#modal-container"));
                    $("#VerifyImage", $obj).click();//重新加载验证码
                    $("#verifycode").val("");
                    $(".modal-error", $obj).html(data.message);
                },
                complete: function () {
                    DialogLoading({ id: id }, false);
                }
            });
        }
    });
}


//处理AJAX返回结果
function ajaxDone(data) {
    var flag = true;
    try {
        var jsonData = typeof (data) == "string" ? $.parseJSON(htmlDecode(data)) : data;
        switch (jsonData.statusCode.toString()) {
            case "301":
                flag = false;
                LoginDialog(jsonData.message);
                break;
            case "300":
                flag = false;
                msgerr({ message: jsonData.message });
                break;
            case "200":
                flag = true;
                if (jsonData.HandelCode.toString() == "1") location.reload();
                break;
            case "400":
                flag = false;
                msgwar({ message: jsonData.message });
                break;
            default:
                break;
        }
    } catch (e) {
        flag = true;
    }
    return flag;
}